import React from "react";
import {Drawer} from "antd"

import BaseComponent from "../../../../redare/components/BaseComponent";
import {WebPage} from "../../utils/WorkbenchDecoratorUtil";
import UserGrid from "../../components/user/UserGrid";
import UserDetail from "../../components/user/UserDetail";

export default @WebPage({
    module: '通用组件',
    classify: '用户管理',
    id: 'com.redare.webplatform.workbench.pages.user.UserManagePage',
    name: '平台用户管理',
    webPath: '/user/manager',
    webFunIds: [
        'WebPlatformUserAdd',
        'WebPlatformUserModifyInfo',
        'WebPlatformUserModifyPassword',
        'WebPlatformUserModifyMenu',
        'WebPlatformUserModifyRole',
        'WebPlatformUserModifyStatus',
        'WebPlatformUserDel'
    ]
})
class UserManagePage extends BaseComponent {

    constructor(props) {
        super(props);
        this.state.detail = {visible: false};
    }

    render() {
        return <>
            <UserGrid onUserSelected={(record) => this.setState({detail: {visible: true, id: record.id}})}/>
            <Drawer
                title='用户详情'
                width='500'
                destroyOnClose={true}
                visible={this.state.detail.visible}
                onClose={() => {
                    this.setState({
                        detail: {visible: false}
                    })
                }}
            >
                <UserDetail
                    id={this.state.detail.id}
                    onCancel={() => {
                        this.setState({
                            detail: {visible: false}
                        })
                    }}/>
            </Drawer>
        </>;
    }
}
